package org.apache.lucene.store;

import java.io.IOException;
import java.util.Random;

public class RandomDataDirectoryGenerator {

	public static final int filesToTestWith = 10;
	
	public static Directory buildLargeTestDirectory() throws IOException {
		Random rand = new Random();
		Directory dir = new GAERAMDirectory("largetestdir");
		for (int i = 1; i <= filesToTestWith; i++) {
			IndexOutput output = dir.createOutput("file_" + i);
			byte[] data = new byte[1024*(i % 2 == 0 ? rand.nextInt(512) + 768 : 8) + (i % 3 == 0 ? rand.nextInt(1022) + 1 : 0)];
			rand.nextBytes(data);
			output.writeBytes(data, data.length);
			output.close();
		}
		
		return dir;
	}
	
	public static Directory buildTinyTestDirectory() throws IOException {
		Directory dir = new GAERAMDirectory("tinytestdir");
		for (int i = 1; i <= filesToTestWith; i++) {
			IndexOutput output = dir.createOutput("file_" + i);
			output.writeString("file_" + i);
			output.close();
		}
		
		return dir;
	}
	
}
